using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;

namespace ns20
{
	internal sealed class Class144<T> : DynamicMetaObject
	{
		private delegate DynamicMetaObject Delegate2(DynamicMetaObject errorSuggestion);

		private sealed class Class145 : GetMemberBinder
		{
			internal Class145(InvokeMemberBinder binder)
				: base(binder.Name, binder.IgnoreCase)
			{
			}

			public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class Class146
		{
			public Class144<T> class144_0;

			public GetMemberBinder getMemberBinder_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_0)
			{
				return getMemberBinder_0.FallbackGetMember(class144_0, dynamicMetaObject_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class147
		{
			public Class144<T> class144_0;

			public SetMemberBinder setMemberBinder_0;

			public DynamicMetaObject dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return setMemberBinder_0.FallbackSetMember(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		[CompilerGenerated]
		private sealed class Class148
		{
			public Class144<T> class144_0;

			public DeleteMemberBinder deleteMemberBinder_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_0)
			{
				return deleteMemberBinder_0.FallbackDeleteMember(class144_0, dynamicMetaObject_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class149
		{
			public Class144<T> class144_0;

			public ConvertBinder convertBinder_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_0)
			{
				return convertBinder_0.FallbackConvert(class144_0, dynamicMetaObject_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class150
		{
			public Class144<T> class144_0;

			public InvokeMemberBinder invokeMemberBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return invokeMemberBinder_0.FallbackInvokeMember(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}

			public DynamicMetaObject method_1(DynamicMetaObject dynamicMetaObject_1)
			{
				return invokeMemberBinder_0.FallbackInvoke(dynamicMetaObject_1, dynamicMetaObject_0, null);
			}
		}

		[CompilerGenerated]
		private sealed class Class151
		{
			public Class144<T> class144_0;

			public CreateInstanceBinder createInstanceBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return createInstanceBinder_0.FallbackCreateInstance(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		[CompilerGenerated]
		private sealed class Class152
		{
			public Class144<T> class144_0;

			public InvokeBinder invokeBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return invokeBinder_0.FallbackInvoke(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		[CompilerGenerated]
		private sealed class Class153
		{
			public Class144<T> class144_0;

			public BinaryOperationBinder binaryOperationBinder_0;

			public DynamicMetaObject dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return binaryOperationBinder_0.FallbackBinaryOperation(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		[CompilerGenerated]
		private sealed class Class154
		{
			public Class144<T> class144_0;

			public UnaryOperationBinder unaryOperationBinder_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_0)
			{
				return unaryOperationBinder_0.FallbackUnaryOperation(class144_0, dynamicMetaObject_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class155
		{
			public Class144<T> class144_0;

			public GetIndexBinder getIndexBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return getIndexBinder_0.FallbackGetIndex(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		[CompilerGenerated]
		private sealed class Class156
		{
			public Class144<T> class144_0;

			public SetIndexBinder setIndexBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject dynamicMetaObject_1;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_2)
			{
				return setIndexBinder_0.FallbackSetIndex(class144_0, dynamicMetaObject_0, dynamicMetaObject_1, dynamicMetaObject_2);
			}
		}

		[CompilerGenerated]
		private sealed class Class157
		{
			public Class144<T> class144_0;

			public DeleteIndexBinder deleteIndexBinder_0;

			public DynamicMetaObject[] dynamicMetaObject_0;

			public DynamicMetaObject method_0(DynamicMetaObject dynamicMetaObject_1)
			{
				return deleteIndexBinder_0.FallbackDeleteIndex(class144_0, dynamicMetaObject_0, dynamicMetaObject_1);
			}
		}

		private readonly Class86<T> class86_0;

		private readonly bool bool_0;

		private static readonly Expression[] expression_0 = new Expression[0];

		[CompilerGenerated]
		private static Func<DynamicMetaObject, UnaryExpression> func_0;

		private T Prop_0 => (T)base.Value;

		internal Class144(Expression expression, T value, Class86<T> proxy, bool dontFallbackFirst)
			: base(expression, BindingRestrictions.Empty, value)
		{
			class86_0 = proxy;
			bool_0 = dontFallbackFirst;
		}

		private bool method_0(string string_0)
		{
			return Class195.smethod_40(class86_0.GetType(), typeof(Class86<T>), string_0);
		}

		public DynamicMetaObject BindGetMember(GetMemberBinder binder)
		{
			if (!method_0("TryGetMember"))
			{
				return base.BindGetMember(binder);
			}
			return method_1("TryGetMember", binder, expression_0, (DynamicMetaObject dynamicMetaObject_0) => binder.FallbackGetMember(this, dynamicMetaObject_0));
		}

		public DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
		{
			if (!method_0("TrySetMember"))
			{
				return base.BindSetMember(binder, value);
			}
			return method_3("TrySetMember", binder, smethod_0(value), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackSetMember(this, value, dynamicMetaObject_1));
		}

		public DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
		{
			if (!method_0("TryDeleteMember"))
			{
				return base.BindDeleteMember(binder);
			}
			return method_4("TryDeleteMember", binder, expression_0, (DynamicMetaObject dynamicMetaObject_0) => binder.FallbackDeleteMember(this, dynamicMetaObject_0));
		}

		public  DynamicMetaObject BindConvert(ConvertBinder binder)
		{
			if (!method_0("TryConvert"))
			{
				return base.BindConvert(binder);
			}
			return method_1("TryConvert", binder, expression_0, (DynamicMetaObject dynamicMetaObject_0) => binder.FallbackConvert(this, dynamicMetaObject_0));
		}

		public DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
		{
			if (!method_0("TryInvokeMember"))
			{
				return base.BindInvokeMember(binder, args);
			}
			Delegate2 @delegate = (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackInvokeMember(this, args, dynamicMetaObject_1);
			DynamicMetaObject dynamicMetaObject = method_2("TryInvokeMember", binder, smethod_1(args), method_2("TryGetMember", new Class145(binder), expression_0, @delegate(null), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackInvoke(dynamicMetaObject_1, args, null)), null);
			if (!bool_0)
			{
				return @delegate(dynamicMetaObject);
			}
			return dynamicMetaObject;
		}

		public DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args)
		{
			if (!method_0("TryCreateInstance"))
			{
				return base.BindCreateInstance(binder, args);
			}
			return method_1("TryCreateInstance", binder, smethod_1(args), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackCreateInstance(this, args, dynamicMetaObject_1));
		}

		public DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
		{
			if (!method_0("TryInvoke"))
			{
				return base.BindInvoke(binder, args);
			}
			return method_1("TryInvoke", binder, smethod_1(args), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackInvoke(this, args, dynamicMetaObject_1));
		}

		public DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
		{
			if (!method_0("TryBinaryOperation"))
			{
				return base.BindBinaryOperation(binder, arg);
			}
			return method_1("TryBinaryOperation", binder, smethod_0(arg), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackBinaryOperation(this, arg, dynamicMetaObject_1));
		}

		public DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
		{
			if (!method_0("TryUnaryOperation"))
			{
				return base.BindUnaryOperation(binder);
			}
			return method_1("TryUnaryOperation", binder, expression_0, (DynamicMetaObject dynamicMetaObject_0) => binder.FallbackUnaryOperation(this, dynamicMetaObject_0));
		}

		public DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes)
		{
			if (!method_0("TryGetIndex"))
			{
				return base.BindGetIndex(binder, indexes);
			}
			return method_1("TryGetIndex", binder, smethod_1(indexes), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackGetIndex(this, indexes, dynamicMetaObject_1));
		}

		public DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
		{
			if (!method_0("TrySetIndex"))
			{
				return base.BindSetIndex(binder, indexes, value);
			}
			return method_3("TrySetIndex", binder, smethod_2(indexes, value), (DynamicMetaObject dynamicMetaObject_2) => binder.FallbackSetIndex(this, indexes, value, dynamicMetaObject_2));
		}

		public DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes)
		{
			if (!method_0("TryDeleteIndex"))
			{
				return base.BindDeleteIndex(binder, indexes);
			}
			return method_4("TryDeleteIndex", binder, smethod_1(indexes), (DynamicMetaObject dynamicMetaObject_1) => binder.FallbackDeleteIndex(this, indexes, dynamicMetaObject_1));
		}

		private static Expression[] smethod_0(params DynamicMetaObject[] dynamicMetaObject_0)
		{
			return dynamicMetaObject_0.Select((DynamicMetaObject dynamicMetaObject_0) => Expression.Convert(dynamicMetaObject_0.Expression, typeof(object))).ToArray();
		}

		private static Expression[] smethod_1(DynamicMetaObject[] dynamicMetaObject_0)
		{
			return new NewArrayExpression[1] { Expression.NewArrayInit(typeof(object), smethod_0(dynamicMetaObject_0)) };
		}

		private static Expression[] smethod_2(DynamicMetaObject[] dynamicMetaObject_0, DynamicMetaObject dynamicMetaObject_1)
		{
			return new Expression[2]
			{
				Expression.NewArrayInit(typeof(object), smethod_0(dynamicMetaObject_0)),
				Expression.Convert(dynamicMetaObject_1.Expression, typeof(object))
			};
		}

		private static ConstantExpression smethod_3(DynamicMetaObjectBinder dynamicMetaObjectBinder_0)
		{
			Type type = dynamicMetaObjectBinder_0.GetType();
			while (!type.smethod_11())
			{
				type = type.smethod_6();
			}
			return Expression.Constant(dynamicMetaObjectBinder_0, type);
		}

		private DynamicMetaObject method_1(string string_0, DynamicMetaObjectBinder dynamicMetaObjectBinder_0, Expression[] expression_1, Delegate2 delegate2_0, Delegate2 delegate2_1 = null)
		{
			DynamicMetaObject dynamicMetaObject_ = delegate2_0(null);
			DynamicMetaObject dynamicMetaObject = method_2(string_0, dynamicMetaObjectBinder_0, expression_1, dynamicMetaObject_, delegate2_1);
			if (!bool_0)
			{
				return delegate2_0(dynamicMetaObject);
			}
			return dynamicMetaObject;
		}

		private DynamicMetaObject method_2(string string_0, DynamicMetaObjectBinder dynamicMetaObjectBinder_0, Expression[] expression_1, DynamicMetaObject dynamicMetaObject_0, Delegate2 delegate2_0)
		{
			ParameterExpression parameterExpression = Expression.Parameter(typeof(object), null);
			IList<Expression> list = new List<Expression>();
			list.Add(Expression.Convert(base.Expression, typeof(T)));
			list.Add(smethod_3(dynamicMetaObjectBinder_0));
			list.smethod_1(expression_1);
			list.Add(parameterExpression);
			DynamicMetaObject dynamicMetaObject = new DynamicMetaObject(parameterExpression, BindingRestrictions.Empty);
			if (dynamicMetaObjectBinder_0.ReturnType != typeof(object))
			{
				UnaryExpression expression = Expression.Convert(dynamicMetaObject.Expression, dynamicMetaObjectBinder_0.ReturnType);
				dynamicMetaObject = new DynamicMetaObject(expression, dynamicMetaObject.Restrictions);
			}
			if (delegate2_0 != null)
			{
				dynamicMetaObject = delegate2_0(dynamicMetaObject);
			}
			return new DynamicMetaObject(Expression.Block(new ParameterExpression[1] { parameterExpression }, Expression.Condition(Expression.Call(Expression.Constant(class86_0), typeof(Class86<T>).GetMethod(string_0), list), dynamicMetaObject.Expression, dynamicMetaObject_0.Expression, dynamicMetaObjectBinder_0.ReturnType)), method_5().Merge(dynamicMetaObject.Restrictions).Merge(dynamicMetaObject_0.Restrictions));
		}

		private DynamicMetaObject method_3(string string_0, DynamicMetaObjectBinder dynamicMetaObjectBinder_0, Expression[] expression_1, Delegate2 delegate2_0)
		{
			DynamicMetaObject dynamicMetaObject = delegate2_0(null);
			ParameterExpression parameterExpression = Expression.Parameter(typeof(object), null);
			IList<Expression> list = new List<Expression>();
			list.Add(Expression.Convert(base.Expression, typeof(T)));
			list.Add(smethod_3(dynamicMetaObjectBinder_0));
			list.smethod_1(expression_1);
			list[expression_1.Length + 1] = Expression.Assign(parameterExpression, list[expression_1.Length + 1]);
			DynamicMetaObject dynamicMetaObject2 = new DynamicMetaObject(Expression.Block(new ParameterExpression[1] { parameterExpression }, Expression.Condition(Expression.Call(Expression.Constant(class86_0), typeof(Class86<T>).GetMethod(string_0), list), parameterExpression, dynamicMetaObject.Expression, typeof(object))), method_5().Merge(dynamicMetaObject.Restrictions));
			if (!bool_0)
			{
				return delegate2_0(dynamicMetaObject2);
			}
			return dynamicMetaObject2;
		}

		private DynamicMetaObject method_4(string string_0, DynamicMetaObjectBinder dynamicMetaObjectBinder_0, Expression[] expression_1, Delegate2 delegate2_0)
		{
			DynamicMetaObject dynamicMetaObject = delegate2_0(null);
			IList<Expression> list = new List<Expression>();
			list.Add(Expression.Convert(base.Expression, typeof(T)));
			list.Add(smethod_3(dynamicMetaObjectBinder_0));
			list.smethod_1(expression_1);
			DynamicMetaObject dynamicMetaObject2 = new DynamicMetaObject(Expression.Condition(Expression.Call(Expression.Constant(class86_0), typeof(Class86<T>).GetMethod(string_0), list), Expression.Empty(), dynamicMetaObject.Expression, typeof(void)), method_5().Merge(dynamicMetaObject.Restrictions));
			if (!bool_0)
			{
				return delegate2_0(dynamicMetaObject2);
			}
			return dynamicMetaObject2;
		}

		private BindingRestrictions method_5()
		{
			if (Prop_0 == null && base.HasValue)
			{
				return BindingRestrictions.GetInstanceRestriction(base.Expression, null);
			}
			return BindingRestrictions.GetTypeRestriction(base.Expression, base.LimitType);
		}

		public IEnumerable<string> GetDynamicMemberNames()
		{
			return class86_0.ns20_002EClass86_003CNewtonsoft_002EJson_002ELinq_002EJObject_003E_002E_202D_206C_200E_202A_202E_206E_206F_202C_202B_200C_200B_206D_202E_206F_206F_206B_206F_200B_206A_206B_202B_202E_206C_202B_202D_206C_206B_206D_200E_202D_202D_206F_202B_202D_200B_202D_200B_206D_200E_200E_202E(Prop_0);
		}

		[CompilerGenerated]
		private static UnaryExpression smethod_4(DynamicMetaObject dynamicMetaObject_0)
		{
			return Expression.Convert(dynamicMetaObject_0.Expression, typeof(object));
		}
	}
}
